package com.room.service;

import com.room.mapper.WorkmanMapper;
import com.room.pojo.Student;
import com.room.pojo.Workman;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建人 lin
 * @创建时间 2019/10/13
 * @描述
 */
@Service
public class WorkService {
    @Autowired
    WorkmanMapper workmanMapper;

    public Workman getWorkmanByNo(String workNo){
        return workmanMapper.getWorkmanByNo(workNo);
    }

    //修改员工数据
    public int updateWorkman(Workman workman){
        if(workman!=null){
           return workmanMapper.updateByPrimaryKey(workman);
        }
        return 0;
    }


    //根据分页获取技工数据
    public List<Workman> getWorkByPage(Integer page, Integer size){
        int start  = (page-1)* size;
        return workmanMapper.getWorkByPage(start,size);
    }

    public long getTotal(){
        return workmanMapper.getTotal();
    }

    //根据传进的id删除学生数据
    public boolean deleteWorkById(String ids){
        String[] split = ids.split(",");
//        for(int i=0;i<split.length;i++){
//            String studentNo =  studentMapper.getStuNoById(split[i]);
//            Long rid =  userMapper.getUserIdByUserName(studentNo);
//            userMapper.deleteUserByUserName(studentNo);
//            roleMapper.deleteRoleByUid(rid);
//
//        }
//        return studentMapper.deleteStuById(split) == split.length;
        return workmanMapper.deleteWorkById(split)==split.length;
    }
}
